<%--
    Created on : 2019
    Author     : 黄忠
--%>

<%@page import="java.util.ArrayList"%>
<%@ page import="friendManager.FriendBean" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>个人信息管理系统->修改联系人</title>
    <link rel="stylesheet" href="../CSS/infor.css">
</head>
<body bgcolor="CCCFFF">
<%
    String userName=request.getParameter("userName");
    ArrayList friendslist=(ArrayList)session.getAttribute("friendslist");
%>
<br>
<div id="showUpdate">
    <div style="float: left;width: 100%">
        <button style="float: right;" onclick="closeUpdate()">关闭</button>
    </div>
    <form action="http://localhost:8080/UpdateFriendServlet?userName=<%=userName%>" method="post">
        <table border="2" cellspacing="0" cellpadding="0" style="width: 90%;" align="center">
            <%
            if(userName!=null){
                FriendBean nf = null;
                for(int i=friendslist.size()-1;i>=0;i--) {
                    nf = (FriendBean) friendslist.get(i);
                    if(nf.getName().equals(userName)) break;
            }
            %>
            <tr>
                <td>用户姓名</td>
                <td><input required="required" value="<%=nf.getName()%>" type="text" name="name"/></td>
            </tr>
            <tr>
                <td>用户电话</td>
                <td><input required="required" value="<%=nf.getPhone()%>" type="text" name="phone"/></td>
            </tr>
            <tr>
                <td>邮箱</td>
                <td><input required="required" value="<%=nf.getEmail()%>" type="email" name="email"/></td>
            </tr>
            <tr>
                <td>工作单位</td>
                <td><input required="required" value="<%=nf.getWorkPlace()%>" type="text" name="workPlace"/></td>
            </tr>
            <tr>
                <td>家庭住址</td>
                <td><input required="required" value="<%=nf.getPlace()%>" type="text" name="place"/></td>
            </tr>
            <tr>
                <td>用户QQ</td>
                <td><input required="required" value="<%=nf.getQQ()%>" type="text" name="QQ"/></td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <input type="submit" value="确 定" size="12">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="reset" value="清 除" size="12">
                </td>
            </tr>
            <%
                }
            %>
        </table>
    </form>
    <br>
</div>
<br>
    <%
        if(friendslist==null||friendslist.size()==0){
    %>
    <div align="center">
        <h1>您还没有任何联系人！</h1>
    </div>
    <%
    } else{
    %>
        <table cellspacing="0" cellpadding="0" style="width: 99%;" align="center">
            <tr>
                <th>姓名</th>
                <th>电话</th>
                <th>邮箱</th>
                <th>工作单位</th>
                <th>家庭住址</th>
                <th>QQ</th>
                <th>操作</th>
            </tr>
        </table>
        <table id="pageMain" cellspacing="0" cellpadding="0" style="width: 99%;" align="center">
    <%
        for(int i=friendslist.size()-1;i>=0;i--){
            FriendBean ff=(FriendBean)friendslist.get(i);
    %>
    <tr class="hoverTr">
        <td><%=ff.getName()%></td>
        <td><%=ff.getPhone()%></td>
        <td><%=ff.getEmail()%></td>
        <td><%=ff.getWorkPlace()%></td>
        <td><%=ff.getPlace()%></td>
        <td><%=ff.getQQ()%></td>
        <td><a href="http://localhost:8080/friendManager/updateFriend.jsp?userName=<%=ff.getName()%>">修改</a></td>
    </tr>
    <%
            }
        }
    %>
</table>
</body>
<%@include file="../page.jsp" %>
</html>
<script src="../JS/update.js"></script>
<script>
    window.onload=function () {
        if(getArgs("userName")!=null){
            showUpdate();
        }
    }
</script>

